<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/9/13
  Time: 10:43
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>

    <meta charset="UTF-8">
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

    <!-- 可选的 Bootstrap 主题文件（一般不用引入） -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap-theme.min.css" integrity="sha384-6pzBo3FDv/PJ8r2KRkGHifhEocL+1X2rVCTTkUfGk7/0pbek5mMa1upzvWbrUbOZ" crossorigin="anonymous">

    <!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
    <script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
    <title>ERP系统 - 房屋信息管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/css/main.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/static/lib/font-awesome/css/font-awesome.css">
    <script src="<%=request.getContextPath()%>/static/lib/jquery/jquery.js" type="text/javascript"></script>
    <script type="text/javascript">

        function selectedValue() {
           if($("#select").find("option:selected").text()=="出租状态"){
                    $("#tishi").text("0表示禁止出租，1表示已出租，2表示未出租请输入正确的条件")
           }
        }
        function empty1() {
            $("#tishi").text("");
        }
    </script>
</head>
    <body>
    <div class="box">
        <h3>房屋信息管理</h3>
        <div class="actions" >
            <div >
                <shiro:hasPermission name="sys:house:add">
                    <a class="btn btn-primary" href="addHouse">添加房屋信息</a>
                </shiro:hasPermission>

                <br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>
                <shiro:hasPermission name="sys:house:select">
                    <form class="form-inline" action="searchHouse" method="get">
                        <select id="select" name="field" >
                            <option value="hArea" onclick="empty1()">所属地区</option>
                            <option value="hEstate" onclick="empty1()">所属小区</option>
                            <option value="hAcreage" onclick="empty1()">房屋面积</option>
                            <option value="hPrice" onclick="empty1()">出租价格</option>
                            <option value="hStatus" onclick="selectedValue()">出租状态</option>
                        </select>
                        <input type="text" id="search" name="keyword" placeholder="输入关键字查询">
                        <input type="submit" value="搜索">
                        <label id="tishi" ></label>
                    </form>
                </shiro:hasPermission>


            </div>
        </div>

        <table class="list">
            <tr>
                <th>序号</th>
                <th>所属地区</th>
                <th>所属小区</th>
                <th>单元号</th>
                <th>所属楼层</th>
                <th>房间号</th>
                <th>面积</th>
                <th>朝向</th>
                <th>装修</th>
                <th>是否双气</th>
                <th>限住人数</th>
                <th>配套设施</th>
                <th>出租价格</th>
                <th>出租状态</th>
                <th>房屋图片</th>
                <th>完整地址信息</th>
                <th>信息添加时间</th>
                <th>信息最后更新时间</th>
                <th>操作</th>
            </tr>
            <c:forEach var="house" items="${list.list}" varStatus="status">

                    <tr>
                        <td>${house.hId}</td>
                        <td>${house.hArea}</td>
                        <td>${house.hEstate}</td>
                        <td>${house.hUnitnumber}</td>
                        <td>${house.hFloor}</td>
                        <td>${house.hRoomno}</td>
                        <td>${house.hAcreage}</td>
                        <td>${house.hDirection}</td>
                        <td>${house.hFitment}</td>
                        <td>${house.hIsdoubleair}</td>
                        <td>${house.hLimit}</td>
                        <td>${house.hFacility}</td>
                        <td>${house.hPrice}</td>

                        <c:if test="${house.hStatus==1}">
                            <td>已出租</td>
                        </c:if>
                        <c:if test="${house.hStatus==0}">
                            <td>停止出租</td>
                        </c:if>
                        <c:if test="${house.hStatus==2}">
                            <td>未出租</td>
                        </c:if>

                        <td>${house.hImg}</td>
                        <td>${house.hAddress}</td>
                        <td>${house.hAddtime}</td>
                        <td>${house.hUpdatetime}</td>
                        <td>
                            <shiro:hasPermission name="sys:house:delete">
                                <button onclick="delHouse(${house.hId})">删除</button>
                            </shiro:hasPermission>
                            <shiro:hasPermission name="sys:house:update">
                                <button onclick="editHouse(${house.hId})">编辑</button>
                            </shiro:hasPermission>
                            <button onclick="detailHouse(${house.hId})">详情</button>
                        </td>
                    </tr>


            </c:forEach>
        </table>

        <div>共有 ${list.total} 条记录，第 ${list.pageNum}/${list.pages} 页 </div>
            <nav aria-label="Page navigation">
                <ul class="pagination">
                    <li><a href="<%=request.getContextPath() %>/getAllHouse?pn=1">首页</a></li>
                    <c:if test="${list.hasPreviousPage }">

                        <li>
                            <a href="<%=request.getContextPath() %>/getAllHouse?pn=${list.pageNum-1}" aria-label="Previous">
                                <span aria-hidden="true">&laquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <c:forEach items="${list.navigatepageNums }" var="page_Num">
                        <c:if test="${page_Num==list.pageNum} ">
                            <li class="active"><a href="#">${pageNum}</a></li>
                        </c:if><li><a href="<%=request.getContextPath() %>/getAllHouse?pn=${page_Num}">${page_Num}</a></li>


                    </c:forEach>
                    <c:if test="${list.hasNextPage }">
                        <li>
                            <a href="<%=request.getContextPath() %>/getAllHouse?pn=${list.pageNum+1}" aria-label="Next">
                                <span aria-hidden="true">&raquo;</span>
                            </a>
                        </li>
                    </c:if>
                    <li><a href="<%=request.getContextPath() %>/getAllHouse?pn=${list.pages}">末页</a></li>
                </ul>
            </nav>


    </div>
    </div>
    </body>
<script type="text/javascript">
    function delHouse(id) {
       if (confirm("你确定要删除吗")){
         window.location.href="${pageContext.request.contextPath}/delHouse?h_id="+id;
       }

    }
    function detailHouse(id) {
        window.location.href="${pageContext.request.contextPath}/detailHouse?h_id="+id;

    }
    function editHouse(id){
        window.location.href="${pageContext.request.contextPath}/editHouse?h_id="+id;
    }

</script>
</html>
